/**
 * @summary 搜索模块
 * @author yang
 */
import * as searchApi from '@/api/search'
export default {
  namespaced: true,
  state: {
    // 搜索列表
    searchList: [],
    // 搜索结果
    searchResult: [],


  },
  mutations: {
    SET_SEARCH_LIST(state, newValue) {
      state.searchList = newValue;
    },
    SET_SEARCH_RESULT(state, newValue) {
      state.searchResult = newValue;
    },
  },
  actions: {
    async updatesearchList({ commit }, q) {
      const res = await searchApi.getSearchList(q);
      commit('SET_SEARCH_LIST', res);
    },
    async updatesearchResult({ commit }, q) {
      const res = await searchApi.getSearchResult(q);
      commit('SET_SEARCH_RESULT', res);
      // console.log('3', res);
    }
  }
}
